home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / database / postgres / mpsql-1.001 / mpsql-1~ / mpsql-1.0 / db.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-28  |  3.6 KB  |  109 lines

  1. /************************************************************************/
  2. /* File   : db.h                                    */
  3. /* Purpose: db data module header                            */
  4. /* By     : Keith R. Davis                            */
  5. /* Date   : 12/11/95                                    */
  6. /* Notes  : Copyright(c) 1996 White River Software            */
  7. /*          Copyright(c) 1994, Regents of the University of California  */
  8. /************************************************************************/
  9.  
  10. #ifndef _DB_H
  11. #define _DB_H
  12.  
  13. #define String PQString
  14. #include <libpq-fe.h>                   /* postgres lib                         */
  15. #undef String
  16.  
  17.  
  18. #define ERR_MSG_SIZE 5120               /* max error message size               */
  19. #define DATA_SIZE 2048                  /* max len of a single line in a query  */
  20. #define MAX_PATH_LEN 2048               /* max length of a file path            */
  21. #define QY_BUFFER_SIZE 8191             /* max size of a single query statement */
  22. #define COPYBUFSIZ 8192                 /* max copy buffer size                 */ 
  23. #define RSLT_BUFFER_SIZE 1073741823     /* max size of data in the result win.  */
  24. #define DB_NAME_SZ 255                  /* max size of db name                  */
  25. #define HOST_NAME_SZ 255                /* max size of host name                */
  26. #define PORT_NAME_SZ 10                 /* max size of port id                  */
  27. #define PRINT_NAME_SZ 255               /* max size of printer name             */
  28. #define COL_SZ 5                        /* max size of col width field          */
  29.  
  30. /* database globals */        
  31. extern PGconn *db;                /* db ptr        */
  32. extern char dbname[];                /* db name ptr        */
  33. extern char host[];                /* host name ptr    */
  34. extern char port[];                /* port ptr        */
  35. extern char spool_file[];               /* spool file           */
  36. extern char printer[];                  /* printer              */
  37. extern int col_width;                   /* default column width */ 
  38. extern char col_sep;                    /* column separator char*/
  39.  
  40.  
  41. /* database functions */
  42.  
  43. /* connect to database                    */
  44. int  DB_Connect(void);
  45.  
  46. /* disconnect from database            */
  47. void DB_Close(void);                 
  48.  
  49.  /* submits a query to the database         */
  50. int  DB_SubmitQy(void);                 
  51.  
  52. /* open a sql file                         */
  53. int  DB_OpenFile(char *file);           
  54.  
  55. /* save buffer to its file                 */  
  56. int  DB_SaveFile(LLISTbuffer *buffer);  
  57.  
  58. /* prints query results */
  59. void DB_PrintTuples(char *qy, PGresult *res, char *fout, int Spool, int PrintAttNames, 
  60.             int Echo, int colWidth, char sep);
  61.  
  62. /* writes a string to the result window    */
  63. void DB_WriteToResult(char *data, int spool, FILE *file); 
  64.  
  65. /* writes a string to the SQL window       */
  66. void DB_WriteToSQL(char *data);
  67.  
  68. /* writes a string to the specified buffer */
  69. void DB_WriteToBuffer(char *data, Widget w); 
  70.  
  71. /* opens a new scratch buffer              */
  72. LLISTbuffer* DB_OpenScratchBuffer(void); 
  73.  
  74. /* set the SQL window to the spec, buffer  */
  75. LLISTbuffer* DB_SetBuffer(LLISTbuffer *buffer); 
  76.  
  77. /* set the app's main window title         */
  78. void DB_SetTitle(char *win_title);
  79.  
  80. /* deletes a buffer                        */
  81. void DB_DeleteBuffer(LLISTbuffer *buffer);
  82.  
  83. /* print buffer contents                   */
  84. void DB_PrintBuffer(LLISTbuffer *buffer, char *printer); 
  85.  
  86. /* checks for modified buffers             */
  87. int DB_ChkModBuffers(void);     
  88.  
  89. /* removes text from top of buffer         */
  90. void DB_ShrinkBuffer(Widget w);
  91.  
  92. /* handles the copy command requests       */
  93. void DB_HandleCopyOut(PGresult *res);
  94. void DB_HandleCopyIn(PGresult *res);
  95.  
  96. /* grab and ungrab events                  */
  97. void DB_Grab(void);
  98. void DB_UnGrab(void);
  99.  
  100. #endif    
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.